package cn.sdormitory.controller.smartdor;

import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.smartdor.service.ExternalInterfaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @className: ExternalInterfaceController
 * @author: Alex
 * @date: 2024/9/25
 **/
@Api(tags = "对外接口")
@RestController
@RequestMapping("/external/interface")
public class ExternalInterfaceController {
	
	@Autowired
	ExternalInterfaceService externalInterfaceService;
	
	@ApiOperation("接收校门进出信息")
	@PostMapping("/receiveSchoolGateEntryAndExitInfo")
	public CommonResult receiveSchoolGateEntryAndExitInfo(@RequestBody List<Map<String, String>> records) throws ParseException {
		Boolean flag = externalInterfaceService.receiveSchoolGateEntryAndExitInfo(records);
		if (flag) {
			return CommonResult.success();
		} else {
			return CommonResult.failed();
		}
	}

}
